const state = {
    list: [],
    page: {}
}
const actions = {
    save_list: ({ commit }, payload) => {
        commit('SAVELIST', payload)
    }
}
const mutations = {
    SAVELIST: (state, payload) => {
        if (payload.result.length === 0) {
            state.list = []
        } else {
            state.list = payload.result.map(item => {
                return {
                    id: item.id,
                    publicAt: item.public_at,
                    title: item.title,
                    subTitle: item.sub_title,
                    isRecommend: item.is_recommend,
                    isTop: item.is_top,
                    content: item.content,
                    fTypeId: item.f_type_id,
                    origin: item.origin,
                    author: item.author,
                    state: item.state,
                    imgUrl: item.img_url,
                    description: item.description,
                    clickTimes: item.click_times
                }
            })
        }
        state.page = {
            number: payload.number || 1,
            size: 10,
            total: payload.resultNum
        }
    }
}

export default {
    state,
    actions,
    mutations
}